$(function () {
    $("[type=submit]").on("click", function (e) {
        e.preventDefault();
        // console.log(this);
        let username = $("[name=userName]").val().trim();
        let password = $("[name=userPwd]").val().trim();
        password = md5(password);
        // console.log(username, password);
        $.ajax({
            url: 'http://127.0.0.1:3000/user/register',
            type: 'POST',
            data: {
                username,
                password
            },
            dataType: 'json',
            success: (res) => {
                // console.log(res);
                if (res.code != 200) {
                    console.log(res);
                    return;
                }
                window.location.href = "./login.html";
            }
        })

    })
})